//package com.example.invoker.schedule.flurry.repurchase;
//
//import cn.hutool.json.JSONObject;
//import com.biapp.appboard.mapper.installation.RepurchaseClickTimesMapper;
//import com.biapp.appboard.pojo.model.flurry.FlurryFiltersInfo;
//import com.biapp.appboard.pojo.model.flurry.FlurryRepurchaseEum;
//import com.biapp.appboard.pojo.model.installation.RepurchaseClickTimes;
//import com.biapp.appboard.service.schedule.flurry.EventParamsSyncService;
//import com.biapp.common.util.ZonedDateUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.*;
//
///**
// * @Author huaiyu yin
// * @Date 2021/7/6 5:01 下午
// * @Version 1.0
// */
//@Service
//public class RepurchaseSyncService extends EventParamsSyncService {
//    /**
//     * 1.获取flurry平台数据
//     * 2.统计安卓和ios数量
//     * 3.数据处理
//     * 4.保存数据
//     */
//    @Autowired
//    private RepurchaseClickTimesMapper repurchaseClickTimesMapper;
//
//
//    @Override
//    public Map<String, Object> getParamsMap() {
//        Map<String, Object> paramsMap = new HashMap<>();
//        FlurryFiltersInfo filtersInfo = new FlurryFiltersInfo();
//
//        filtersInfo.setEventName("use_count");
//        filtersInfo.setParamName("mall_click");
//        paramsMap.put("metrics", getMetrics());
//        paramsMap.put("dateTime", startDate + "/" + endDate);
//
//        paramsMap.put("filters", filtersInfo.getFilters());
//        return paramsMap;
//    }
//
//    @Override
//    public Collection assemblyData(List<JSONObject> jsonObjectList) {
//        Map<String, RepurchaseClickTimes> result = new LinkedHashMap<>();
//        for (JSONObject jsonObject : jsonObjectList) {
//            String date = jsonObject.getStr("dateTime").substring(0,10);
//            String paramValue = jsonObject.getStr("paramValue|name");
//            Integer count = jsonObject.getInt("count");
//            RepurchaseClickTimes vo = null;
//          if(FlurryRepurchaseEum.isExist(paramValue)){
//              vo = result.get(date+paramValue);
//              if(null == vo){
//                  vo = new RepurchaseClickTimes();
//                  vo.setDailyDate(ZonedDateUtil.convertStrgDateToDateInt(date));
//                  vo.setDailyYear(vo.getDailyDate()/10000);
//                  vo.setDailyMonth(ZonedDateUtil.getIntYearMonth(date));
//                  vo.setDailyWeek(ZonedDateUtil.getIntYearWeek(date));
//                  vo.setClickNum(0);
//              }
//              vo.setType(FlurryRepurchaseEum.getNameByName(paramValue));
//              vo.setClickNum(vo.getClickNum() + count);
//              result.put(date+paramValue,vo);
//          }
//        }
//        return new ArrayList<>(result.values());
//    }
//
//    @Override
//    public void save(Collection entityList) {
//        if(entityList.isEmpty()){
//            return;
//        }else{
//            repurchaseClickTimesMapper.batchInsert((List<RepurchaseClickTimes>) entityList);
//        }
//
//    }
//}
